<template>
  <ul class="right-list-container">
    <li v-for="(item, i) in list" :key="i" class="nested-li">
      <a class="nested-name" :class="{active: item.isSelected}" @click="handleClick(item)">
        <span style="margin-right: 1em">{{item.name}}</span>
        <span v-if="item.articleCount" style="font-size: 12px">{{item.articleCount+'篇'}}</span>
      </a>
      <RightList v-if="item.children" :list="item.children" @select="handleClick"></RightList>
    </li>
  </ul>
</template>

<script>
export default {
  name: "RightList",
  props: {
    list: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {

    }
  },
  methods: {
    handleClick(item) {
      if (!item.isSelected) {
        this.$emit('select', item)
      }
    }
  }
}
</script>

<style scoped lang="less">
@import "~@/styles/var.less";
.right-list-container{
  .right-list-container{
    margin-left: 1em;
  }
  .nested-li{
    .nested-name{
      display: block;
      cursor: pointer;
      padding: 10px;
    }
    .active{
      color: @primary;
      font-weight: bold;
    }
  }
}
ul{
  list-style: none;
}
</style>
